<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script>
			//定义数组
			var arr1=[3,5,7];
			//给数组添加求和方法
			arr1.sum=function () {
				var sum=0;
				for(var i=0;i<arr1.length;i++){
					sum+=arr1[i];
				}
				return sum;
			};
			//调用查看结果
			console.log(arr1.sum());
		</script>
	</body>
</html>
